<?php

namespace app\weixin\controller;


use think\Db;
use think\Request;

class News extends \think\Controller
{
    public function index()
    {

        $s = input('param.');

        if (IS_AJAX()) {


        } else {
             
            $where['State']=3; 
            $where['BusModelID'] = $s['cateid'] ? $s['cateid'] : 1;
            if($s['tagid']){

                $where['InfoCategoryID']=$s['tagid'];
            }
            $list = Db::table('news')->field('Content',true)->where($where)->order('id desc')->limit(20)->select();
            $this->assign('list', $list);


            $catelist = Db::table('news_cate')->where(['ParentID' => 0, 'Level' => 1])->cache(60)->select();
            $taglist=Db::table('news_cate')->where(['ParentID' => $where['BusModelID'], 'Level' => 2])->cache(60)->select();
            $this->assign('catelist', $catelist);
            $this->assign('taglist',$taglist);
            $catename=idtoval('news_cate',['ID'=>$where['BusModelID']],'CategoryName');
            $this->assign('catename',$catename);
            $this->assign('act', $where['BusModelID']);

            return view();

        }


    }

    public function news()
    {

        $id = input('id');
        $t = Db::table('news')->find($id);
        Db::table('news')->where('ID', $id)->setInc('PageNum');
        $this->assign('t', $t);
        $catelist = Db::table('news_cate')->where(['ParentID' => 0, 'Level' => 1])->cache(60)->select();
        $this->assign('catelist', $catelist);
        return view();
    }


}
